home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / xmm12.zip / XMM.ASM < prev    next >
Assembly Source File  |  1992-07-05  |  60KB  |  1,555 lines

  1. ;--------------------------------------------------------------------------
  2. ;  MODULE :        XMM                           INITIAL : 19891127 v 1.00
  3. ;  AUTHOR :        Jeroen W. Pluimers            UPDATE :  19920705 v 1.20
  4. ;
  5. ;  DESCRIPTION :   eXtended Memory Manager
  6. ;
  7. ;  HISTORY :       19891127 - 1.00 - jwp
  8. ;
  9. ;                      initial translation from XMS 2.0 specification
  10. ;
  11. ;                  19909322 - 1.11 - jwp
  12. ;
  13. ;                      final XMS 2.0 implementation
  14. ;
  15. ;                  19920705 - 1.20 - jwp
  16. ;
  17. ;                      incorporation of XMS 3.0 specification
  18. ;
  19. ;                      incorporation of XMS 3.0 specification
  20. ;                      compiled for Turbo Pascal 6.0
  21. ;                      documentation fixup for XMS 3.0
  22. ;
  23. ;  COMPUTER :      NEAT-AT, ERC 386/25
  24. ;  COMPILER :      TASM 1.0, TASM 2.01
  25. ;  LINKER :        TURBO PASCAL 5.0, 5.5 and 6.0
  26. ;
  27. ;  COPYRIGHT :     (c) 1989-1992 Pluimers Software Ontwikkeling.
  28. ;--------------------------------------------------------------------------
  29.                 Ideal
  30.                 Masm51
  31.  
  32.                 %title  "XMM - eXtended Memory Manager"
  33.                 %pagesize 70,132
  34.  
  35.                 Model   TPascal
  36.  
  37.                 DataSeg
  38. ;----------------------------------------------------------------------------
  39. ; there is nothing in the data segment.
  40. ;----------------------------------------------------------------------------
  41.  
  42.                 CodeSeg
  43.  
  44. ;----------------------------------------------------------------------------
  45. ; Macro to convert from XMS success/fail to
  46. ; a form more acceptable for TURBO PASCAL.  IE.
  47. ;
  48. ; AX =  1 becomes AL = 0
  49. ; AX <> 1 becomes AL = BL
  50. ;----------------------------------------------------------------------------
  51. Macro       SuccessFail
  52. Local       Success
  53.  
  54.     dec    ax
  55.     jz    Success
  56.         mov     al, bl
  57. Success:
  58.  
  59. EndM
  60.  
  61.  
  62.  
  63.  
  64. ;----------------------------------------------------------------------------
  65. ; Initialised data must reside in the code segment.
  66. ;----------------------------------------------------------------------------
  67.  
  68. XMM_Initialised dw      0
  69.  
  70. ; XMM_Control points to a routine that returns XMMNotInitialised (80h)
  71. ; for each XMM call until XMMInstalled is called.
  72.  
  73. label   XMM_Control     DWord
  74.                 dw      OFFSET XMM_NotInitialised
  75.                 dw      Code
  76.  
  77.  
  78.  
  79.  
  80. ;---------------------------------------------------------------------------
  81. ;  ROUTINE :     XMM_NotInitialised
  82. ;
  83. ;  DESCRIPTION : Routine called for each XMM function call, when the XMM
  84. ;                is not initialised with a call to XMMInstalled.
  85. ;
  86. ;  RETURNS :     XMMNotInitialised.
  87. ;---------------------------------------------------------------------------}
  88. Proc   XMM_NotInitialised FAR
  89.  
  90.             xor     ax, ax                          ; Immediate failure
  91.             mov     bl, 80h                         ; Not Implemented
  92.  
  93.             ret
  94.  
  95. EndP
  96.  
  97.  
  98.  
  99.  
  100. ;---------------------------------------------------------------------------
  101. ;  ROUTINE :     XMMInstalled
  102. ;
  103. ;  DESCRIPTION : THIS ROUTINE MUST BE CALLED BEFORE ANY OTHER ROUTINE
  104. ;                OR ALL THE OTHER ROUTINES WILL FAIL WITH ERROR CODE $80.
  105. ;
  106. ;  RETURNS :     False - No XMM driver found.
  107. ;                True  - An XMM driver has been found.
  108. ;
  109. ;  POST :        Internal pointer to XMM driver is established.
  110. ;
  111. ;  PASCAL :      Function XMMInstalled : Boolean;
  112. ;---------------------------------------------------------------------------
  113. Proc    XMMInstalled    FAR
  114. Public  XMMInstalled
  115.  
  116.             cmp     [XMM_Initialised], 0
  117.             jne     @@Already_Initialised
  118.             mov     ax, 4300h                       ; Test for XMM
  119.             int     2fh
  120.             cmp     al, 80h
  121.             jne     @@NoDriver
  122.  
  123.             mov     ax, 4310h                       ; Get Control Function
  124.             int     2fh
  125.             mov     [word ptr cs:XMM_Control], bx
  126.             mov     [word ptr cs:XMM_Control+2], es
  127.             inc     [XMM_Initialised]
  128.  
  129.     @@NoDriver:
  130.  
  131.     @@Already_Initialised:
  132.  
  133.             mov     ax, [XMM_Initialised]
  134.  
  135. EndP
  136.  
  137.  
  138.  
  139.  
  140. ;---------------------------------------------------------------------------
  141. ;  ROUTINE :     XMMVersion
  142. ;
  143. ;  DESCRIPTION : Get version numbers. Both the XMS version number and the
  144. ;                driver internal revision number are encoded as follows :
  145. ;                  Low byte  = minor part.
  146. ;                  High byte = major part.
  147. ;                e.g. XMSversion $0277 would mean version 2.77.
  148. ;                The HMAAvailable indicates the existence of the HMA (not
  149. ;                its availability) and is intended mainly for installation
  150. ;                programs.
  151. ;
  152. ;  OUT :         XMSversion   - XMS version number.
  153. ;                XMSrevision  - Driver internal revision number.
  154. ;                HMAAvailable - False - no HMA detected.
  155. ;                               True  - HMA has been detected.
  156. ;
  157. ;  RETURNS :     XMMNotImplemented - XMMInstalled has not been called.
  158. ;                XMMOk             - Always if XMMInstalled has been called.
  159. ;
  160. ;  PRE :         XMMInstalled must have been called first.
  161. ;
  162. ;  PASCAL :      Function XMMVersion(Var XMSversion,
  163. ;                                        XMSrevision  : Word;
  164. ;                                    Var HMAAvailable : Boolean) : Byte;
  165. ;
  166. ;  XMS :         ARGS:   AH = 00h
  167. ;                RETS:   AX = XMS version number (BCD encoded)
  168. ;                        BX = Driver internal revision number.
  169. ;                        DX = 0001h if the HMA exists, 0000h otherwise.
  170. ;                ERRS:   None.
  171. ;---------------------------------------------------------------------------}
  172. Proc    XMMVersion  FAR XMSVersion   : DWord,   \
  173.                         Revision     : DWord,   \
  174.                         HMAAvailable : DWord
  175. Public  XMMVersion
  176.  
  177.             xor     ah,ah                       ; Function 0
  178.             call    [XMM_Control]
  179.  
  180.             les     di,[XMSVersion]
  181.             mov     [Word Ptr es:di],ax
  182.  
  183.             les     di,[Revision]
  184.             mov     [Word Ptr es:di],bx
  185.  
  186.             les     di,[HMAAvailable]
  187.             mov     [Word Ptr es:di],dx
  188.  
  189.             xor     al,al                       ; return XMMOk
  190.  
  191.             ret
  192.  
  193. EndP
  194.  
  195.  
  196.  
  197.  
  198. ;---------------------------------------------------------------------------
  199. ;  ROUTINE :     XMMRequestHMA
  200. ;
  201. ;  DESCRIPTION : Attempts to reserve the whole 64K-16 byte high memory
  202. ;                area for the caller.
  203. ;                If the HMA is currently unused, the caller's size
  204. ;                parameter is compared to the /HMAMIN= parameter on
  205. ;                the driver's command line.
  206. ;                If the value passed by the caller is greater than or
  207. ;                equal to the amount specified by the driver's
  208. ;                parameter, the request succeeds.
  209. ;                This provides the ability to ensure that programs
  210. ;                which use the HMA efficiently have priority over
  211. ;                those which do not.
  212. ;                NOTE: See the sections "Prioritizing HMA Usage" and
  213. ;                      "High Memory Area Restrictions" in the
  214. ;                      documentation for more information.
  215. ;
  216. ;  IN :          SpaceNeeded - Number of bytes in the HMA needed by caller.
  217. ;                              It is recommended that if the caller is
  218. ;                              an application program this value is
  219. ;                              set to 65535 and if the caller is a TSR
  220. ;                              the real number of bytes is used.
  221. ;
  222. ;  RETURNS :     XMMOk              - the HMA is assigned to the caller.
  223. ;                XMMNotImplemented  - the function is not implemented.
  224. ;                XMMVDiskFound      - a VDISK device is detected.
  225. ;                XMMHMANotExist     - the HMA does not exist.
  226. ;                XMMHAMInUse        - the HMA is already in use.
  227. ;                XMMHAMMinSize      - SpaceNeeded is less than the /HMAMIN=
  228. ;                                     env